Problem

Say you want to automate clicking and navigation with AppleScript, but don’t know the UI Elements of the window in order to actually do so

Solution

open the Automator.app, then choose Workflow

press record

click around what you want automated, then stop recording

select all in red above, and copy. then paste into some TextEditor (example of what’s copy below)

-- Mouse Clicked
delay 4.117081
set timeoutSeconds to 2.000000
set uiScript to "click image \"LR -3\" of group 1 of scroll area 1 of application process \"Finder\""
my doWithTimeout( uiScript, timeoutSeconds )
...

copy the snippet at line 4 and paste into the AppleScript like below (NOTE: un-escape the “)

tell application "System Events"
    tell process "Finder"
		click image "LR -3" of group 1 of scroll area 1
    end tell
end tell

Example Scripts